package com.ms3ds.mineInfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ms3ds.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ms3ds.common.log.annotation.Log;
import com.ms3ds.common.log.enums.BusinessType;
import com.ms3ds.common.security.annotation.RequiresPermissions;
import com.ms3ds.mineInfo.api.domain.OreType;
import com.ms3ds.mineInfo.service.IOreTypeService;
import com.ms3ds.common.core.web.controller.BaseController;
import com.ms3ds.common.core.web.domain.AjaxResult;
import com.ms3ds.common.core.utils.poi.ExcelUtil;
import com.ms3ds.common.core.web.page.TableDataInfo;

/**
 * 矿物种类Controller
 * 
 * @author zlw
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/oreType")
public class OreTypeController extends BaseController
{
    @Autowired
    private IOreTypeService oreTypeService;

    /**
     * 查询矿物种类列表
     */
    @RequiresPermissions("mineInfo:oreType:list")
    @GetMapping("/list")
    public TableDataInfo list(OreType oreType)
    {
        startPage();
        List<OreType> list = oreTypeService.selectOreTypeList(oreType);
        return getDataTable(list);
    }

    @GetMapping("/getAll")
    public AjaxResult getAll(OreType oreType)
    {
        List<OreType> list = oreTypeService.selectOreTypeList(oreType);
        return success(list);
    }

    @GetMapping("/getOreTypeByIdForremote")
    public R<OreType> getOreTypeByIdForremote(Long oreTypeId){
        OreType type = oreTypeService.selectOreTypeById(oreTypeId);
        return R.ok(type);
    }

    /**
     * 导出矿物种类列表
     */
    @RequiresPermissions("mineInfo:oreType:export")
    @Log(title = "矿物种类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OreType oreType)
    {
        List<OreType> list = oreTypeService.selectOreTypeList(oreType);
        ExcelUtil<OreType> util = new ExcelUtil<OreType>(OreType.class);
        util.exportExcel(response, list, "矿物种类数据");
    }

    /**
     * 获取矿物种类详细信息
     */
    @RequiresPermissions("mineInfo:oreType:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(oreTypeService.selectOreTypeById(id));
    }

    /**
     * 新增矿物种类
     */
    @RequiresPermissions("mineInfo:oreType:add")
    @Log(title = "矿物种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OreType oreType)
    {
        return toAjax(oreTypeService.insertOreType(oreType));
    }

    /**
     * 修改矿物种类
     */
    @RequiresPermissions("mineInfo:oreType:edit")
    @Log(title = "矿物种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OreType oreType)
    {
        return toAjax(oreTypeService.updateOreType(oreType));
    }

    /**
     * 删除矿物种类
     */
    @RequiresPermissions("mineInfo:oreType:remove")
    @Log(title = "矿物种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oreTypeService.deleteOreTypeByIds(ids));
    }
}
